package fudan.se.project.util.date;


import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author Gao Longchao
 */
@Component
public class DateUtils {

    public static final long ONE_DAY_TIME = 24L * 60 * 60 * 1000;


    public boolean isRightOutOfRightBorderByOneDay(Date leftBorder, Date testee) {
        Date rightBorder = new Date(leftBorder.getTime() + ONE_DAY_TIME);
        if (rightBorder.before(testee)) {
            return testee.getTime() - rightBorder.getTime() < ONE_DAY_TIME;
        }
        return false;
    }

    public boolean isLeftOutOfRightBorder(Date leftBorder, Date testee) {
        Date rightBorder = new Date(leftBorder.getTime() + ONE_DAY_TIME);
        return rightBorder.after(testee);
    }
}
